//
//  BaseTableViewCell.h
//  MyFunctionDemo
//
//  Created by Ting Han on 2017/9/21.
//  Copyright © 2017年 Ting Han. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "CellDataAdapter.h"
@class BaseTableViewCell;
@protocol BaseTableViewCellDelegate <NSObject>

@optional
- (void)baseCell:(BaseTableViewCell *)baseCell event:(id)event;

@end

@interface BaseTableViewCell : UITableViewCell

@property (nonatomic,weak) id<BaseTableViewCellDelegate> baseCellDelegate;

@property (nonatomic,strong) CellDataAdapter *dataAdapter;
@property (nonatomic,strong) id data;
+ (CGFloat)cellHeightWithData:(id)data;

#pragma mark ---
@property (nonatomic,weak) UITableView *tableView;
@property (nonatomic,weak) NSIndexPath *indexPath;
@property (nonatomic,weak) UIViewController *viewController;
@property (nonatomic,assign) BOOL display;

#pragma mark --- 点击事件，被调用或者重写
- (void)selectedEvent;
#pragma mark --- 被重写

- (void)setupCell;
- (void)buildSubview;
- (void)loadContent;

#pragma mark --- 注册cell
+ (void)registerToTableView:(UITableView *)tableView
            reuseIdentifier:(NSString *)reuseIdentifier;
+ (void)registerNibToTableView:(UITableView *)tableView
            reuseIdentifier:(NSString *)reuseIdentifier;
+ (void)registerToTableView:(UITableView *)tableView;
+ (void)registerNibToTableView:(UITableView *)tableView;

@end

@interface UITableView(BaseCell)

- (BaseTableViewCell *)dequeueReusableCellAndLoadDataWithAdapter:(CellDataAdapter *)dataAdapter indexPath:(NSIndexPath *)indexPath;

- (BaseTableViewCell *)dequeueReusableCellAndLoadDataWithAdapter:(CellDataAdapter *)dataAdapter delegate:(id <BaseTableViewCellDelegate>)delegate indexPath:(NSIndexPath *)indexPath;
- (CGFloat)cellHeightWithAdapter:(CellDataAdapter *)adapter;

@end

